package com.cake.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cake.base.util.ReturnUtils;
import com.cake.entity.XxBanner;
import com.cake.service.inter.IXxBannerService;

/**
 * banner控制层
 */
@RestController
@RequestMapping(value = "banner")
public class BannerController {
	
	@Autowired
	private IXxBannerService xxBannerService;
	
	/**
	 * 获取所有的banner
	 * @return
	 */
	@GetMapping(value = "selectBanners")
	public Object selectBanners(HttpServletRequest request){
		return xxBannerService.selectBanners();
	}
	
	/**
	 * 根据id查询banner详情
	 * @param bannerId
	 * @return
	 */
	@GetMapping(value = "selectBannerById")
	public Object selectBannerById(Long bannerId){
		return xxBannerService.selectBannerById(bannerId);
	}
	
	/**
	 * 修改banner的信息
	 * @param xxBanner
	 * @return
	 * @throws Exception 
	 */
	@PostMapping(value = "updateBanner")
	public Object updateBanner(@RequestBody XxBanner xxBanner) throws Exception{
		return xxBannerService.updateBannerAndBannerImage(xxBanner);
	}
	
	/**
	 * 获取商品列表基本信息
	 * @return
	 * @throws Exception 
	 */
	@GetMapping(value = "selectProductBasicInfoForBanner")
	public Object selectProductBasicInfoForBanner() throws Exception{
		return ReturnUtils.forNoramlSuccess(xxBannerService.selectProductBasicInfoForBanner());
	}
	
	/**
	 * 获取商品分类基本信息
	 * @return
	 * @throws Exception 
	 */
	@GetMapping(value = "selectProductCategoryBasicInfoForBanner")
	public Object selectProductCategoryBasicInfoForBanner() throws Exception{
		return ReturnUtils.forNoramlSuccess(xxBannerService.selectProductCategoryBasicInfoForBanner());
	}
}
